<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      let sum = 0;
      while (true) {
        const x = prompt("number?");
        if (x === null) {
          //用户按下了取消键
          break;
        } else {
          console.log(x);
          // 将用户的输入累加
          sum += +x;
        }
      }

      console.log(sum);
    </script>
  </body>
</html>
